import torch

# 创建一个 3000 行的 tensor
tensor = torch.randn(16, 3000, 10, 20)

# 生成一个随机排列的索引
indices = torch.randperm(tensor.size(1))[:1000]

# 使用索引选择数据
selected_tensor = tensor[:, indices, :, :]

print(selected_tensor.shape)  # 输出: torch.Size([1000, 10])